package com.wtsw.pulsosocial.view.menu;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.widget.LoginButton;
import com.facebook.widget.ProfilePictureView;
import com.wtsw.pulsosocial.FullscreenActivity;
import com.wtsw.pulsosocial.R;
import com.wtsw.pulsosocial.controller.GestorUsuario;

public class CuentaFragment extends Fragment {
    private ProfilePictureView profilePictureView;
    private TextView greeting;
    private TextView email;
    private TextView id;
    private LoginButton logout;
    
    public static Fragment newInstance(Context context) {
        CuentaFragment f = new CuentaFragment();
        return f;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {    	    
        View rootView = inflater.inflate(R.layout.fragment_cuenta, container, false);
        profilePictureView = (ProfilePictureView) rootView.findViewById(R.id.profilePicture);
        greeting = (TextView) rootView.findViewById(R.id.greeting);
        email = (TextView) rootView.findViewById(R.id.email);
        id = (TextView) rootView.findViewById(R.id.id);
        logout = (LoginButton) rootView.findViewById(R.id.authButton);
        
        profilePictureView.setProfileId(GestorUsuario.getUsuario().getId());
        greeting.setText(GestorUsuario.getUsuario().getNombre()+" "+GestorUsuario.getUsuario().getApellido());
        email.setText(GestorUsuario.getUsuario().getEmail());
        id.setText(GestorUsuario.getUsuario().getId());        
        logout.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	startActivity(new Intent(getActivity(), FullscreenActivity.class));
    	        getActivity().finish();
            }
        });
        
        return rootView;
    }

}
